<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>制作冲红申请单 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="capFund_form">
    <div class="fieldset1 tabel_col clearFix">
        <div class="caption">
            <span class="title">来款信息</span>
        </div>
        <div class="fieldBox col_33">
            <div class="label">资金编号</div>
            <div class="field">
                ${capFundVO.code}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">凭证种类</div>
            <div class="field">
                ${capFundVO.certificateCd}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">凭证号码</div>
            <div class="field">
                ${capFundVO.certificateCode}
            </div>
        </div>

        <div class="fieldBox col_33">
            <div class="label">资金状态</div>
            <div class="field">
                ${capFundVO.fundStatusCdNm}
            </div>
        </div>

        <div class="fieldBox col_33">
            <div class="label">收款户名</div>
            <div class="field">
                ${capFundVO.acceptName}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">收款账号</div>
            <div class="field">
                ${capFundVO.acceptCode}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">来款户名</div>
            <div class="field">
                ${capFundVO.comeName}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">来款账户</div>
            <div class="field">
                ${capFundVO.comeCode}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">收到金额</div>
            <div class="field">
                <span id="comeAmt"></span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">客户名称</div>
            <div class="field">
                ${capFundVO.cstNm}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">资金到账日期</div>
            <div class="field">
                ${capFundVO.acceptDates}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">实际到账日期</div>
            <div class="field">
                ${capFundVO.acceptActualDates}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">待分解金额</div>
            <div class="field">
                <span id="availableAmt" style="color: red;"></span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">导入人</div>
            <div class="field">
                ${capFundVO.crtUsrNm}
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">认款人</div>
            <div class="field">
                ${capFundVO.identifyOperatorNm}
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">摘要</div>
            <div class="field">
                ${capFundVO.docketRem}
            </div>
        </div>
    </div>

    <input id="available" type="text" hidden value="${capFundVO.availableAmount}">
    <div class="fieldset1 tabel_col clearFix">
        <div class="caption">
            <span class="title">资金分解明细</span>
        </div>
        <div class="fieldBox col_100">
            <div id="ligergrid_dtllist" class="sq-grid"></div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">冲红原因</div>
            <div class="field">
                <textarea name="fundRedRem" id="fundRedRem" class="ui-textarea l-textarea" style="width:99%" value=""
                          rows="4" cols="120" validate="{required:false,maxlength:1000}"></textarea>
            </div>
        </div>
        <div class="btnsBox">
            <span id="revert_Btn" class="sq-button sq-button-round l-dialog-btn-ok">申请冲红</span>
            <span id="back_Btn" class="sq-button sq-button-round l-dialog-btn-ok">返回</span>
            <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
        </div>
    </div>
</form>
<script>
    var payListGrid=null;
    var balance=0;
    $(function () {
        $("#comeAmt").text(FormatMoney(parseFloat('${capFundVO.amount}')/100));
        $("#availableAmt").text(FormatMoney(parseFloat('${capFundVO.availableAmount}')/100));
        var fundId='${capFundVO.id}';//资金ID
        var vfId='${vfId}';//分解、冲红ID

        payListGrid = $("#ligergrid_dtllist").ligerGrid({
            url: '<%=path%>/capital/capFund/searchVfDtlList.do',
            parms:{fundId:fundId,vfId:vfId},
            method: 'get',
            columns: [
                {display: '分解单号', name: 'vfNo', minWidth: 100,align:'center'},
                {display: '支付表号', name: 'paySchNo', width: 170 ,align:'center'},
                {display: '应收项目', name: 'feeTypCdNm', minWidth: 100,align:'center'},
                {display: '应收日期', name: 'payDt', minWidth: 100,render:renderDate,align:'center'},
                {display: '应收金额', name: 'payFeeAmt', minWidth: 100,align:'right',
                    render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.payFeeAmt/100);
                    }
                },
                {display: '实收金额', name: 'vfAmt', minWidth: 100,align:'right',
                    render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.vfAmt/100);
                    }
                },
                {display: '查看', width: 100,name:'vfStsCdNm',align:'center'},
            ],
            isDisabledSelect: function (item) {
                if(item.vfStsCd!=2) return true;
            },
            usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            isScroll: false,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            hideCheckAll: true,
        });

        $("#capFund_form").ligerForm({
            validate: true
        });

        //申请冲红
        $("#revert_Btn").click(function (){
            var selectedRows = payListGrid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }

            $.ligerDialog.confirm("是否确认发起冲红流程?", function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids:JSON.stringify(_ids),vfRem:$("#fundRedRem").val(),fundId:fundId,vfId:vfId},
                    url: '<%=path%>/capital/capFund/revertFundApply.do',
                    beforeSend: function () {
                        wait_dialog = top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            payListGrid.reload();
                            $("#resetBtn").click();
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success",SQ_showButtons : true,});
                            Remove_navTab();
                        } else {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error",SQ_showButtons : true});
                        }
                    }
                });
            });
        });

        //返回
        $("#back_Btn").click(function (){
            Remove_navTab();
        });

    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>
</body>
</html>
